package yf.mall.vo.app.common;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: fly-boot
 * @ClassName JsonResult
 * @description:
 * @author: yxmds
 * @create: 2023-07-11 15:55
 * @Version 1.0
 **/
@Data
public class DataResult {

    @JSONField(name = "success")
    private Boolean success;

    @JSONField(name = "result")
    @Valid
    private Object result;

    public DataResult(Boolean success, Object result) {
        this.success = success;
        this.result = result;
    }

    public DataResult(Boolean success, String result, boolean isJson) {
        this.success = success;
        if (isJson) {
            this.result = JSON.parse(result);
        } else {
            this.result = result;
        }
    }
}
